package com.zrrd.mybatis_02.mapper;

import com.zrrd.mybatis_02.entity.Course;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @author WanJl
 * @version 1.0
 * @title CourseMapper
 * @description 课程Mapper
 * @create 2024/10/18
 */
public interface CourseMapper {
    /**
     * 根据学生id查询该学生选择的课程列表
     * @param studentId
     * @return
     */
    @Select("SELECT c.id cour_id,c.name cour_name FROM course c LEFT JOIN stu_cr sc " +
            "ON sc.cid=c.id WHERE sc.sid = #{studentId}")
    @Results({
            @Result(column = "cour_id",property = "courseId"),
            @Result(column = "cour_name",property = "courseName")
    })
    List<Course> selectCourseByStudentId(Integer studentId);
}
